package com.iplant.base.po;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.po.enums.UserGrads;
import com.iplant.base.utils.BaseConfigConstans;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.general.DesUtil;
import com.iplant.base.utils.general.StringUtils;

import java.io.Serializable;



public class BaseUser extends BasePO implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public static BaseUser SysAdmin = new BaseUser();

	public static String defaultPassword = "123456";

	static {
		SysAdmin.ID = -100;
		SysAdmin.Grad = UserGrads.System.getValue();
		SysAdmin.Name = "SHRIS";
		SysAdmin.LoginName = DesUtil.encrypt("SHRISMCIS");
		SysAdmin.Password = DesUtil.encrypt("shrismcis");

		String wDefaultString = BaseConfigConstans.DefaultPassword;
		if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
			wDefaultString = DesUtil.decrypt(wDefaultString);
			if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
				defaultPassword = wDefaultString;
			}
		}

		wDefaultString = BaseConfigConstans.AdminUser;
		if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
			wDefaultString = DesUtil.decrypt(wDefaultString);
			if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
				wDefaultString = DesUtil.encrypt(wDefaultString);
				SysAdmin.LoginName = wDefaultString;
			}
		}
		wDefaultString = BaseConfigConstans.AdminPassword;;
		if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
			wDefaultString = DesUtil.decrypt(wDefaultString);
			if (StringUtils.isNotEmpty(wDefaultString) && wDefaultString.length() >= 8) {
				wDefaultString = DesUtil.encrypt(wDefaultString);
				SysAdmin.Password = wDefaultString;
			}
		}


	}


	@DBField
	public String LoginName = "";
	@DBField
	public String Password = "";
	@DBField
	public int CompanyID = 0;
	@DBField
	public int Grad = 0;




	public BaseUser() {

	}



	@JsonProperty("LoginName")
	public String getLoginName() {
		return LoginName;
	}

	public void setLoginName(String loginName) {
		LoginName = loginName;
	}
	@JsonProperty("Password")
	public String getPassword() {
		return Password;
	}

	public void setPassword(String password) {
		Password = password;
	}
	@JsonProperty("CompanyID")
	public int getCompanyID() {
		return CompanyID;
	}

	public void setCompanyID(int companyID) {
		CompanyID = companyID;
	}
	@JsonProperty("Grad")
	public int getGrad() {
		return Grad;
	}

	public void setGrad(int grad) {
		Grad = grad;
	}

	@Override
	public void setID(int iD) {
		ID = iD;
	}



}
